<template>
    <div class="home">
        home
        <ul>
            <li>
                <router-link to="/detail/1?title=新闻一">新闻一</router-link>
            </li>
            <li>
                <router-link :to="{name:'detail',params:{id:2},query:{title:'新闻二'}}">新闻二</router-link>
            </li>
        </ul>
    </div>
</template>

<script>
export default {
    beforeRouteEnter (to,from,next){ //进入这个组件之前
        console.log("beforeRouteEnter",this)
        next()
    },
    beforeRouteLeave (to,from,next){//离开这个组件
        console.log("beforeRouteLeave",this)
        next()
    }
}
</script>
<style>

</style>
